package com.blb.eduadservice.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.blb.common.util.ResponseResult;
import com.blb.eduadservice.entity.PromotionAd;
import com.blb.eduadservice.service.IPromotionAdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 广告表 前端控制器
 * </p>
 *
 * @author xray
 * @since 2023-03-31
 */
@RestController
public class PromotionAdController {

    @Autowired
    private IPromotionAdService promotionAdService;

    @GetMapping("ads/space-id/{spaceId}")
    public ResponseResult<List<PromotionAd>> getAdListBySpaceId(@PathVariable Long spaceId){
        List<PromotionAd> adList = promotionAdService.list(new QueryWrapper<PromotionAd>().lambda().eq(PromotionAd::getSpaceId, spaceId));
        return ResponseResult.ok(adList);
    }

}
